import { httpCreate, CommonResponse } from './http';
const http = httpCreate('/srv/user');

export const user = {
	// 测试登录
	testLogin<T>() {
		return http.get<T, CommonResponse>(`/auth/test-login?mobPhone=17636644317`);
	},
	// 获取用户总数
	getUserTotal<T>() {
		return http.get<T, CommonResponse>('/total');
	},
	// 用户管理列表
	getUserAdminList<T>(params: { pageNum: number; pageSize: number; searchText?: string | number }) {
		return http.get<T, CommonResponse>('/list', { params });
	},
	// 新增用户
	addUser<T>(body: {
		nickname: string;
		mobPhone: string | number;
		password: string;
		confirmPassword: string;
		areaCode: string;
	}) {
		return http.post<T, CommonResponse>('/add', body);
	},
	//  详情-基础数据
	getBasicData<T>(userId: number) {
		return http.get<T, CommonResponse>(`/info/${userId}`);
	},
	// 详情-登录记录
	getUserLoginRecords<T>(userId: number, params: { pageNum: number; pageSize: number }) {
		return http.get<T, CommonResponse>(`/loginHistory/${userId}`, { params });
	},
	// 人员管理
	getPersonAdminList<T>(params: { pageNum: number; pageSize: number }) {
		return http.get<T, CommonResponse>('/admin/list', { params });
	},
	// 删除管理员
	deletePersonAdminList<T>(userId: number) {
		return http.delete<T, CommonResponse>(`/admin/${userId}`);
	},
	// 添加管理员
	addPersonAdmin<T>(body: { mobPhone: string }) {
		return http.post<T, CommonResponse>('/admin/add', body);
	},
	// 退出登录
	logout<T>() {
		return http.get<T, CommonResponse>('/auth/logout');
	},
	// 获取用户信息
	getUserInfo<T>(params: object) {
		return http.get<T, CommonResponse>(`/auth/user-info`, { params });
	},
	// 获取超管用户统计数据
	getAdminCount<T>() {
		return http.get<T, CommonResponse>(`/admin/listCount`);
	},
	// 获取管理权限
	getAdminType<T>(userId: number) {
		return http.get<T, CommonResponse>(`/admin/getInfo/${userId}`);
	},
	// 修改登录权限
	updateLoginPermission<T>(userId: number, body: { loginPermission: number }) {
		return http.post<T, CommonResponse>(`/admin/update/${userId}`, body);
	},
	// 获取下拉列表
	getAdminSelectList<T>() {
		return http.get<T, CommonResponse>('/admin/selectList');
	},
};
